package com.morningstar.logger.satoekn;

import cn.dev33.satoken.interceptor.SaInterceptor;
import cn.dev33.satoken.stp.StpUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Slf4j
@Configuration
public class SaTokenConfigure extends WebMvcConfigurationSupport {

    // 注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        log.info("addInterceptors SaInterceptor");
        registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin()))
                .addPathPatterns("/**")
                .excludePathPatterns("/feign/**");

/*        registry.addInterceptor(new FeignInterceptor())
                .addPathPatterns("/feign/**");*/
    }
}
